import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { map } from 'rxjs/operators';

import { ListResult } from 'app/modules/base/api-base';

import { LastUrlService } from '../../services/last-url.service';
import { PcException } from '../../services/pc-exception';

@Component({
    selector: 'm-pc-exception-list',
    templateUrl: './pc-exception-list.component.html',
    styleUrls: ['./pc-exception-list.component.scss']
})
export class PcExceptionListComponent implements OnInit {
    constructor(private route: ActivatedRoute,
        private urlService: LastUrlService) { }

    result$ = this.route.data.pipe(map(data => data['list'] as ListResult<PcException>));

    ngOnInit() {
        this.route.url.subscribe(urls => this.urlService.setURL(urls.join(',')));
    }

    downloadLog(ex: PcException) {
        console.log("Will download:", ex);
    }
}
